package goleetcode

func hIndex(citaions []int) int {
	n := len(citaions)
	l, r := 0, n - 1
	for l <= r {
		mid := l + (r - l) / 2
		if citaions[mid] >= n - mid {
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
	return n - l
}